package com.talkology.pilot.student.service.impl;

import com.talkology.pilot.database.dao.BookingsMapper;
import com.talkology.pilot.database.model.Bookings;
import com.talkology.pilot.student.service.IBookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BookingServiceImpl implements IBookingService {
    @Autowired
    private BookingsMapper mapper;

    @Override
    public List<Bookings> getAllByFilter(String studentId, String teacherName,
                                         String classBegin, String classEnd, String status) {
        return this.mapper.selectByFilter(studentId, teacherName, classBegin, classEnd,status);
    }

    @Override
    public Bookings getInfo(Integer index) {
        return this.mapper.selectByPrimaryKey(index);
    }

    @Override
    @Transactional
    public void add(Bookings record) {
        this.mapper.insert(record);
    }

    @Override
    @Transactional
    public void edit(Bookings record) {
        this.mapper.updateByPrimaryKey(record);
    }

    @Override
    @Transactional
    public void delete(Integer record) {
        this.mapper.deleteByPrimaryKey(record);
    }
}
